﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace StringVariables
{
    public class VariableDefinition
    {
        public string Name { get; set; }
        public string DefaultValue { get; set; }
        public VariableType Type { get; set; }
        public bool AllowNull { get; set; }

        public bool IsValid(string value)
        {
            if (string.IsNullOrEmpty(value) && AllowNull)
                return true;
            if (Type == null) throw new InvalidOperationException("Type is null => can't validate");
            return Type.IsValid(value);
        }
    }
}
